<html>
<head>
<?php include 'utils.php'?>
<title>prueba</title>
	<script type="text/javascript">
	function setlistener(){
		var ve = document.getElementById("ve");
		if(ve != null && ve.addEventListener) {
			ve.addEventListener('ended', 
				function() {
					var sp = <?php echo $_REQUEST['songsplayed']?>;
					sp++;
					window.location = "/index2.php?songsplayed="+sp
				}, 
				false);
		}
	}
	</script>
</head>
	
<body onload="setlistener();">
<?php $st= nextsong();?>
<audio src="<?php echo $st['ruta']?>" id="ve" autoplay controls preload>
</audio>
<p><h2>Ahora suena: <?php echo $st['autor']?> - <?php echo $st['titulo']?></p></h2>
<p><h2>Numero de canciones que han sonado: <?php echo $_REQUEST['songsplayed']?></p></h2>
<?php
echo '<p><h2> canciones en cola:<p></h2><br>';
$ptr=queuelist();
while ($fila = mysql_fetch_array($ptr)) {
    echo $fila['autor']," - ", $fila['titulo'],"<br>";
}
?>
</body>
</html>
